/*
 * Protocol.hpp
 *
 *  Created on: 17 dec. 2012
 *      Author: Admin
 */

#ifndef PROTOCOL_HPP_
#define PROTOCOL_HPP_

#include <string>

#define DISCONNECT "disconnect"
#define TRIGGER "trigger"
#define UPDATE "update"

class Protocol
{
public:
	enum TriggerType
	{
		//0 - 99 = signals
		EMERGENCYSIGNAL = 0,
		PROXIMITYSIGNAL = 1,
		COLLISIONFRONTSIGNAL = 2,
		COLLISIONBACKSIGNAL = 3,
		COLORLANELEFTSIGNAL = 4,
		COLORLANERIGHTSIGNAL = 5,
		CROSSROADSSIGNAL = 6,
		SIDEXITLEFTSIGNAL = 7,
		SIDEEXITRIGHTSIGNAL = 8,
		//100 - 199 = toggles
		EMERGENCYTOGGLE = 100,
		PROXIMITYTOGGLE = 101,
		COLLISIONFRONTTOGGLE = 102,
		COLLISIONBACKTOGGLE = 103,
		COLORLANELEFTTOGGLE = 104,
		COLORLANERIGHTTOGGLE = 105,
		CROSSROADSTOGGLE = 106,
		SIDEEXITLEFTTOGGLE = 107,
		SIDEEXITRIGHTTOGGLE = 108,
		//200 - 299 = commands
		START = 200,
		PAUZE = 201,
		RESTART = 202
	};

	enum UpdateType
	{
		STATUS = 0,
		LEFTWHEEL = 1,
		RIGHTWHEEL = 2,
		LED1 = 3,
		LED2 = 4,
		BUZZER = 5,
		SLEEP = 6,
		WHEELCONTROL = 7,
		COLORLANELEFTSENSOR = 8,
		COLORLANERIGHTSENSOR = 9,
		EMERGENCYSENSOR = 10,
		PROXIMITYSENSOR = 11,
		COLLISIONFRONTSENSOR = 12,
		COLLISIONBACKSENSOR = 13,
		CROSSROADSSENSOR = 14,
		SIDEEXITLEFTSENSOR = 15,
		SIDEEXITRIGHTSENSOR = 16,

		CONNECTION = 100,
		CONNECTIONERROR = 101
	};

	enum WheelStatus
	{
		STOPPED = 0,
		FORWARD = 1,
		BACKWARD = 2
	};

	struct Trigger
	{
		Trigger(TriggerType aType, int aValue) :
			type(aType),
			value(aValue)
		{ }

		Trigger(TriggerType aType) :
			type(aType),
			value(1)
		{ }

		TriggerType type;
		int value;
	};

	static TriggerType getTriggerType(int type)
	{
		return (TriggerType) type;
	}
};


#endif /* PROTOCOL_HPP_ */
